package com.example.everying.model.dto.pay;

import com.google.gson.annotations.SerializedName;

public enum TransferBillStatus {
    @SerializedName("ACCEPTED")
    ACCEPTED,
    @SerializedName("PROCESSING")
    PROCESSING,
    @SerializedName("WAIT_USER_CONFIRM")
    WAIT_USER_CONFIRM,
    @SerializedName("TRANSFERING")
    TRANSFERING,
    @SerializedName("SUCCESS")
    SUCCESS,
    @SerializedName("FAIL")
    FAIL,
    @SerializedName("CANCELING")
    CANCELING,
    @SerializedName("CANCELLED")
    CANCELLED;

    /**
     * 重写toString方法，返回枚举的字符串值
     * @return 枚举名称字符串
     */
    @Override
    public String toString() {
        return name();
    }
    
    /**
     * 检查状态是否表示失败或关闭
     * @param state 状态字符串
     * @return 如果是失败或关闭状态返回true，否则返回false
     */
    public static boolean isFailedOrClosed(String state) {
        return "FAIL".equals(state) || "CANCELING".equals(state) || "CANCELLED".equals(state);
    }
    
    /**
     * 检查状态是否表示失败或正在取消或已取消
     * @param state 状态枚举
     * @return 如果是失败或取消状态返回true，否则返回false
     */
    public static boolean isFailedOrClosed(TransferBillStatus state) {
        return state == FAIL || state == CANCELING || state == CANCELLED || state == WAIT_USER_CONFIRM;
    }
    
    /**
     * 检查状态是否表示成功
     * @param state 状态字符串
     * @return 如果是成功状态返回true，否则返回false
     */
    public static boolean isSuccess(String state) {
        return "SUCCESS".equals(state);
    }
    
    /**
     * 检查状态是否表示成功
     * @param state 状态枚举
     * @return 如果是成功状态返回true，否则返回false
     */
    public static boolean isSuccess(TransferBillStatus state) {
        return state == SUCCESS;
    }
}